/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.grt192.controller.cannonbot;

import com.grt192.core.EventController;
import com.grt192.event.SensorEvent;
import com.grt192.event.component.ButtonListener;
import com.grt192.mechanism.GRTDriverStation;
import com.grt192.mechanism.cannonbot.Target;
import com.grt192.sensor.GRTJoystick;

/**
 *
 * @author Robostudent
 */
public class TargetController extends EventController implements ButtonListener{
    private Target target;

    public TargetController(GRTDriverStation ds, Target target){
        addMechanism("DriverStation", ds);
        addMechanism("Target", target);
        this.target = target;
        ((GRTJoystick) ds.getSensor("rightJoystick")).addButtonListener(this); //could also be left joystick
    }

    public void buttonUp(SensorEvent e, String key) {
        if (key.equals("Button3")) //Button Numbers can change
        {
           if (target.solenoidOut())
           {
               target.withdraw();
           }
        }
    }
    public void buttonDown(SensorEvent e, String key) {
        if (key.equals("Button3"))
        {
           if (!target.solenoidOut())
           {
               target.extend();
           }          
        }

        else if (key.equals("Button4"))
        {
            if (target.solenoidOut())
            {
                target.withdraw();
            }
        }
    }



}
